home *** CD-ROM | disk | FTP | other *** search
- -- pdfclock
- -- shows time when it was created.
-
- RADIUS=200
- MARGIN=20
-
- z = BEGIN (arg[1].."_pdf")
-
- z:set_info( "Creator", "pdfclock.lua")
- z:set_info( "Author", "Thomas Merz")
- z:set_info( "Title", "PDF clock (Lua)")
-
- z:begin_page( 2 * (RADIUS + MARGIN), 2 * (RADIUS + MARGIN))
-
- z:translate( RADIUS + MARGIN, RADIUS + MARGIN)
- z:setcolor( "both", "rgb", 0, 0, 1, 0)
- z:save()
-
- -- minute strokes
- z:setlinewidth( 2)
- for alpha = 0,360-6,6 do
- z:rotate( 6)
- z:moveto( RADIUS, 0)
- z:lineto( RADIUS-MARGIN/3, 0)
- z:stroke()
- end
-
- z:restore()
- z:save()
-
- -- 5 minute strokes
- z:setlinewidth( 3)
- for alpha = 0,360-30,30 do
- z:rotate( 30)
- z:moveto( RADIUS, 0)
- z:lineto( RADIUS-MARGIN, 0)
- z:stroke()
- end
-
- _,_,hour,mins,sec=strfind(getenv("sys$time"),"(%d+):(%d+):(%d+)")
- -- draw hour hand
- z:save()
- z:rotate( -((mins/60) + hour - 3) * 30)
- z:moveto( -RADIUS/10, -RADIUS/20)
- z:lineto( RADIUS/2, 0)
- z:lineto( -RADIUS/10, RADIUS/20)
- z:closepath()
- z:fill()
- z:restore()
-
- -- draw minute hand
- z:setcolor("both","rgb",0,1,0,0)
- z:save()
- z:rotate( -((sec/60) + mins - 15) * 6)
- z:moveto( -RADIUS/10, -RADIUS/20)
- z:lineto( RADIUS * 0.8, 0)
- z:lineto( -RADIUS/10, RADIUS/20)
- z:closepath()
- z:fill()
- z:restore()
-
- -- draw second hand
- z:setcolor( "both", "rgb", 1, 0, 0, 0)
- z:setlinewidth( 2)
- z:save()
- z:rotate( -((sec - 15) * 6))
- z:moveto( -RADIUS/5, 0)
- z:lineto( RADIUS, 0)
- z:stroke()
- z:restore()
-
- -- draw little circle at center
- z:circle( 0, 0, RADIUS/30)
- z:fill()
-
- z:restore()
-
- z:END()